import { takeEvery, put } from "redux-saga/effects";
import { GET_MY_LIST } from "./actionTypes";
import axios from "axios";
import { getListAction } from "./actionCreators";

function* mySagas() {
  yield takeEvery(GET_MY_LIST, getList);
}
function* getList() {
  console.log("saga1");
  // axios
  //   .get("https://mock.apifox.cn/m1/1695860-0-default/todo/list")
  //   .then((res) => {
  //     const data = res.data.data;
  //     const action = getListAction(data);
  //     put(action);
  //   });
  const res = yield axios.get("https://mock.apifox.cn/m1/1695860-0-default/todo/list")
  const action = getListAction(res.data.data)
  yield put(action)
}

export default mySagas;
